<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./css/animate.min.css" />
    <link rel="stylesheet" href="./css/main.css" />
  </head>
  <body>
    <h1>hello model</h1>
    <button onclick="dialog.style.display='flex'">打开</button>
    <div class="model-mask" id="dialog">
      <div class="model-dialog animate__animated animate__backInDown">
        <div class="close" data-action="cancel">X</div>
        <div class="title">hello dialog</div>

        <form>
          <p>姓名 <input type="text" name="" id="" /></p>
          <p>邮箱 <input type="text" name="" id="" /></p>
          <p>手机 <input type="text" name="" id="" /></p>

          <p>
            <button type="button">提交</button>
            <button type="button" data-action="cancel">取消</button>
          </p>
        </form>
      </div>
    </div>
    <script>
      /*
        模态框 css+html
      */

      const dialog = document.getElementById("dialog");

      dialog.onclick = function (e) {
        const action = e.target.dataset.action;
        if (action === "cancel") {
          this.style.display = "none";
        }
      };
    </script>
  </body>
</html>
